package com.javatom.authority;

import org.springframework.security.core.authority.AuthorityUtils;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.security.crypto.password.PasswordEncoder;

import javax.annotation.Resource;

/**
 * 〈功能概述〉<br>
 *
 * @className: MyUserDetailsServiceImpl
 * @package: com.javatom.authority
 * @author: TR
 * @date: 2020/6/21 18:03
 */
public class MyUserDetailsServiceImpl implements UserDetailsService {
    @Resource
    private PasswordEncoder passwordEncoder;

    public UserDetails loadUserByUsername(String s) throws UsernameNotFoundException {
        MyUser user=new MyUser(s,passwordEncoder.encode("javatom"),AuthorityUtils.commaSeparatedStringToAuthorityList("admin"));

        return user;
    }
}